#include<bits/stdc++.h>
#include "graph.h"
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>
	il void read(T &x){
		int f=1;x=0;char c=gc();
		while(c<'0'||c>'9'){
			if(c=='-'){
				f=-1;
			}
			c=gc();
		}
		while(c>='0'&&c<='9'){
			x=x*10+c-48,c=gc();
		}
		x*=f;
	}
	template<typename T,typename ...Args>
	void read(T &x,Args &...args){
		read(x),read(args...);
	}
	template<typename T>
	il void write(T x){
		char buf[43];int len=0;
		if(x<0){
			pc('-'),x=-x;
		}
		do{
			buf[++len]=x%10,x/=10;
		}while(x);
		while(len){
			pc(buf[len--]+'0');
		}
	}
}
using namespace my_std;
const int N=207,M=-1,inf=0x3f3f3f3f,mod=0;
const ll INF=1ll*inf*inf;
int n,m,pw,cur,deg[N],f[N][N],g[N][N],dis[N][N],ans[N];
bool pd[N][N];
void dfs1(int u){
	n++;
	deg[u]=NumberOfRoads();
	rep(i,1,deg[u]){
		Move(i,2);
		if(Color()==2){
			Move(LastRoad(),2);
			continue;
		}
		if(Color()==3){
			Move(LastRoad(),3);
			pd[u][i]=1;
			continue;
		}
		int v=f[u][i]=g[u][i]=++cur;
		int frm=LastRoad();
		dfs1(v);
		Move(frm,3);
	}
}
void dfs2(int u){
	rep(i,1,deg[u]){
		if(f[u][i]){
			Move(i,u/pw%3+1);
			int v=f[u][i],frm=LastRoad();
			dfs2(v);
			Move(frm,v/pw%3+1);
		}else if(pd[u][i]){
			Move(i,u/pw%3+1);
			g[u][i]+=(Color()-1)*pw;
			Move(LastRoad(),Color());
		}
	}
}
void Inspect(int R){
	pw=cur=1,dfs1(1);
	rep(i,0,4){
		dfs2(1);
		pw*=3;
	}
	mems(dis,0x3f);
	rep(i,1,n){
		rep(j,1,deg[i]){
			int u=g[i][j];
			if(u){
				dis[i][u]=dis[u][i]=1;
			}
		}
	}
	rep(k,1,n){
		rep(i,1,n){
			rep(j,1,n){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	rep(i,1,n){
		rep(j,i+1,n){
			ans[dis[i][j]]++;
		}
	}
	rep(i,1,R){
		Answer(i,ans[i]);
	}
}
